package com.ruoyi.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.manage.domain.NursSchedul;
import com.ruoyi.manage.service.INursSchedulService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 护士排班Controller
 * 
 * @author liuyangyang
 * @date 2025-06-10
 */
@RestController
@RequestMapping("/manage/nursschedul")
public class NursSchedulController extends BaseController
{
    @Autowired
    private INursSchedulService nursSchedulService;

    /**
     * 查询护士排班列表
     */
    @PreAuthorize("@ss.hasPermi('manage:nursschedul:list')")
    @GetMapping("/list")
    public TableDataInfo list(NursSchedul nursSchedul)
    {
        startPage();
        List<NursSchedul> list = nursSchedulService.selectNursSchedulList(nursSchedul);
        return getDataTable(list);
    }

    /**
     * 导出护士排班列表
     */
    @PreAuthorize("@ss.hasPermi('manage:nursschedul:export')")
    @Log(title = "护士排班", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NursSchedul nursSchedul)
    {
        List<NursSchedul> list = nursSchedulService.selectNursSchedulList(nursSchedul);
        ExcelUtil<NursSchedul> util = new ExcelUtil<NursSchedul>(NursSchedul.class);
        util.exportExcel(response, list, "护士排班数据");
    }

    /**
     * 获取护士排班详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:nursschedul:query')")
    @GetMapping(value = "/{nursSchedulId}")
    public AjaxResult getInfo(@PathVariable("nursSchedulId") Long nursSchedulId)
    {
        return success(nursSchedulService.selectNursSchedulByNursSchedulId(nursSchedulId));
    }

    /**
     * 新增护士排班
     */
    @PreAuthorize("@ss.hasPermi('manage:nursschedul:add')")
    @Log(title = "护士排班", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody List<NursSchedul> nursScheduls)
    {
        nursSchedulService.insertNursSchedul(nursScheduls);
        return AjaxResult.success("操作成功");
    }

    /**
     * 修改护士排班
     */
    @PreAuthorize("@ss.hasPermi('manage:nursschedul:edit')")
    @Log(title = "护士排班", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NursSchedul nursSchedul)
    {
        return toAjax(nursSchedulService.updateNursSchedul(nursSchedul));
    }

    /**
     * 删除护士排班
     */
    @PreAuthorize("@ss.hasPermi('manage:nursschedul:remove')")
    @Log(title = "护士排班", businessType = BusinessType.DELETE)
	@DeleteMapping("/{nursSchedulIds}")
    public AjaxResult remove(@PathVariable Long[] nursSchedulIds)
    {
        return toAjax(nursSchedulService.deleteNursSchedulByNursSchedulIds(nursSchedulIds));
    }
}
